lake
Lorem ipsum dolor..
revision:
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
Lorem ipsum dolor..
code:
<div class="main">
<h2>Photos</h2>
<div id="myBtnContainer">Select:
<button class="btn active" onclick="filterSelection('all')"> Show all</button>
<button class="btn" onclick="filterSelection('holidays')"> Holidays</button>
<button class="btn" onclick="filterSelection('cars')"> Cars</button>
<button class="btn" onclick="filterSelection('people')"> People</button>
</div>
<div class="row">
<div class="column holidays">
<div class="content">
<img src="../images/1.jpg" alt="lake" style="width:100%">
<h4>lake</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column holidays">
<div class="content">
<img src="../images/2.jpg" alt="beach" style="width:100%">
<h4>beach</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column holidays">
<div class="content">
<img src="../images/4.jpg" alt="bath" style="width:100%">
<h4>bath</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column cars">
<div class="content">
<img src="../images/car1.jpg" alt="Car" style="width:100%">
<h4>Audi</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column cars">
<div class="content">
<img src="../images/car3.jpg" alt="Car" style="width:100%">
<h4>Lamborghini</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column cars">
<div class="content">
<img src="../images/car4.jpg" alt="Car" style="width:100%">
<h4>BMW</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column people">
<div class="content">
<img src="../images/tolkien.jpg" alt="tolkien" style="width:100%">
<h4>Tolkien</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column people">
<div class="content">
<img src="../images/hemingway.jpg" alt="hemingway" style="width:100%">
<h4>Hemingway</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column people">
<div class="content">
<img src="../images/tesla.jpg" alt="tesla" style="width:100%">
<h4>Tesla</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
</div>
</div>
<style>
* {box-sizing: border-box;}
.main {max-width: 99vw;margin: auto;}
h1 {font-size: 50px;word-break: break-all;}
.row {margin: 10px 16px;}
.row, .row > .column {padding: 8px; }
.column {float: left; width: 25%; display: none;}
.row:after {content: ""; display: table; clear: both;}
.content {background-color: white; padding: 10px; }
.content img{width: 25vw; height: 20ve;}
.show {display: block;}
.btn {border: none; outline: none; padding: 12px 16px; background-color: white; cursor: pointer;}
.btn:hover { background-color: #ddd;}
.btn.active {background-color: #666; color: white;}
</style>
<script>
filterSelection("all")
function filterSelection(c) {
var x, i;
x = document.getElementsByClassName("column");
if (c == "all") c = "";
for (i = 0; i < x.length; i++) {
w3RemoveClass(x[i], "show");
if (x[i].className.indexOf(c) > -1) w3AddClass(x[i], "show");
}
}
function w3AddClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
}
}
function w3RemoveClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1);
}
}
element.className = arr1.join(" ");
}
// Add active class to the current button (highlight it)
var btnContainer = document.getElementById("myBtnContainer");
var btns = btnContainer.getElementsByClassName("btn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function(){
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
});
}
</script>